import java.io.*;

/**
 * @ClassName Demo03_BufferedByteArrayStream
 * @Description 字节缓冲流数组复制文件
 * @Author Li
 * @Date 2022/8/12 9:31
 * @ModifyDate 2022/8/12 9:31
 * @Version 1.0
 */
public class Demo03_BufferedByteArrayStream {
    public static void main(String[] args) throws IOException {
        // 记录开始时间
        long sTime = System.currentTimeMillis();
        // 创建缓冲输入流
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("C:\\test.mp3"));
        // 创建缓冲输出流
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D:\\test.mp3"));
        // 将读取的数据写入到输出流
        int len;
        byte[] bytes = new byte[8 * 1024];
        while ((len = bis.read(bytes)) != -1) {
            bos.write(bytes, 0, len);
        }
        // 关闭流
        bos.close();
        bis.close();
        // 记录结束时间
        long eTime = System.currentTimeMillis();
        System.out.println("使用时间为：" + (eTime - sTime) + "ms");
    }
}
